package com.mbl.base.core.common.dto;

import com.mbl.base.config.enums.ResultEnum;
import com.mbl.base.core.modular.oshi.SystemHardwareInfo;
import lombok.Data;

/**
 * 统一返回参数
 */
@Data
public class MblResult {
    public int code;
    public String msg;
    public Object data;

    private MblResult(){}

    public static MblResult renum(ResultEnum resultErrEnum){
        final MblResult mblResult = new MblResult();
        mblResult.setCode(resultErrEnum.getValue());
        mblResult.setMsg(resultErrEnum.getStr());
        return mblResult;
    }

    public static MblResult error(Integer code, String message) {
        final MblResult mblResult = new MblResult();
        mblResult.setCode(code);
        mblResult.setMsg(message);
        return mblResult;
    }

    public static MblResult success(){
        return success(null);
    }

    public static MblResult success(Object data){
        final MblResult mblResult = new MblResult();
        mblResult.setCode(200);
        mblResult.setData(data);
        return mblResult;
    }

}
